/*
 * Practica1View.java
 */

package practica1;

import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;

/**
 * The application's main frame.
 */
public class Practica1View extends FrameView {
    private int numParentesis=0;
    public Practica1View(SingleFrameApplication app) {
        super(app);
        
        initComponents();

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
    }
    
    
    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = Practica1App.getApplication().getMainFrame();
            aboutBox = new Practica1AboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        Practica1App.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        expresion = new javax.swing.JTextArea();
        parIzq = new javax.swing.JButton();
        a = new javax.swing.JButton();
        btnMas = new javax.swing.JButton();
        btnAste = new javax.swing.JButton();
        b = new javax.swing.JButton();
        parDer = new javax.swing.JButton();
        btnAceptar = new javax.swing.JButton();
        btnBorrarTodo = new javax.swing.JButton();
        x = new javax.swing.JButton();
        s = new javax.swing.JButton();
        o = new javax.swing.JButton();
        r = new javax.swing.JButton();
        y = new javax.swing.JButton();
        q = new javax.swing.JButton();
        num6 = new javax.swing.JButton();
        num5 = new javax.swing.JButton();
        num4 = new javax.swing.JButton();
        num3 = new javax.swing.JButton();
        num2 = new javax.swing.JButton();
        num1 = new javax.swing.JButton();
        f = new javax.swing.JButton();
        g = new javax.swing.JButton();
        n = new javax.swing.JButton();
        m = new javax.swing.JButton();
        j = new javax.swing.JButton();
        k = new javax.swing.JButton();
        h = new javax.swing.JButton();
        i = new javax.swing.JButton();
        num8 = new javax.swing.JButton();
        num9 = new javax.swing.JButton();
        l = new javax.swing.JButton();
        num0 = new javax.swing.JButton();
        p = new javax.swing.JButton();
        num7 = new javax.swing.JButton();
        c = new javax.swing.JButton();
        v = new javax.swing.JButton();
        d = new javax.swing.JButton();
        e = new javax.swing.JButton();
        w = new javax.swing.JButton();
        t = new javax.swing.JButton();
        z = new javax.swing.JButton();
        u = new javax.swing.JButton();
        btnBarra = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();

        mainPanel.setMaximumSize(new java.awt.Dimension(500, 500));
        mainPanel.setName("mainPanel"); // NOI18N
        mainPanel.setPreferredSize(new java.awt.Dimension(100, 100));
        mainPanel.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                mainPanelKeyPressed(evt);
            }
        });

        jScrollPane1.setEnabled(false);
        jScrollPane1.setName("jScrollPane1"); // NOI18N

        expresion.setColumns(20);
        expresion.setEditable(false);
        expresion.setRows(5);
        expresion.setName("expresion"); // NOI18N
        expresion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                expresionKeyPressed(evt);
            }
        });
        jScrollPane1.setViewportView(expresion);

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(practica1.Practica1App.class).getContext().getResourceMap(Practica1View.class);
        parIzq.setLabel(resourceMap.getString("parIzq.label")); // NOI18N
        parIzq.setName("parIzq"); // NOI18N
        parIzq.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                parIzqActionPerformed(evt);
            }
        });
        parIzq.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                parIzqKeyPressed(evt);
            }
        });

        a.setLabel(resourceMap.getString("a.label")); // NOI18N
        a.setName("a"); // NOI18N
        a.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aActionPerformed(evt);
            }
        });
        a.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                aKeyPressed(evt);
            }
        });

        btnMas.setEnabled(false);
        btnMas.setLabel(resourceMap.getString("btnMas.label")); // NOI18N
        btnMas.setName("btnMas"); // NOI18N
        btnMas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMasActionPerformed(evt);
            }
        });
        btnMas.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                btnMasKeyPressed(evt);
            }
        });

        btnAste.setEnabled(false);
        btnAste.setLabel(resourceMap.getString("btnAste.label")); // NOI18N
        btnAste.setName("btnAste"); // NOI18N
        btnAste.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAsteActionPerformed(evt);
            }
        });
        btnAste.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                btnAsteKeyPressed(evt);
            }
        });

        b.setLabel(resourceMap.getString("b.label")); // NOI18N
        b.setName("b"); // NOI18N
        b.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bActionPerformed(evt);
            }
        });
        b.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                bKeyPressed(evt);
            }
        });

        parDer.setEnabled(false);
        parDer.setLabel(resourceMap.getString("parDer.label")); // NOI18N
        parDer.setName("parDer"); // NOI18N
        parDer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                parDerActionPerformed(evt);
            }
        });
        parDer.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                parDerKeyPressed(evt);
            }
        });

        btnAceptar.setEnabled(false);
        btnAceptar.setLabel(resourceMap.getString("aceptar.label")); // NOI18N
        btnAceptar.setName("aceptar"); // NOI18N
        btnAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAceptarActionPerformed(evt);
            }
        });
        btnAceptar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                btnAceptarKeyPressed(evt);
            }
        });

        btnBorrarTodo.setText(resourceMap.getString("btnBorrarTodo.text")); // NOI18N
        btnBorrarTodo.setName("btnBorrarTodo"); // NOI18N
        btnBorrarTodo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBorrarTodoActionPerformed(evt);
            }
        });
        btnBorrarTodo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                btnBorrarTodoKeyPressed(evt);
            }
        });

        x.setText(resourceMap.getString("x.text")); // NOI18N
        x.setName("x"); // NOI18N
        x.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                xActionPerformed(evt);
            }
        });
        x.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                xKeyPressed(evt);
            }
        });

        s.setText(resourceMap.getString("s.text")); // NOI18N
        s.setName("s"); // NOI18N
        s.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sActionPerformed(evt);
            }
        });
        s.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                sKeyPressed(evt);
            }
        });

        o.setText(resourceMap.getString("o.text")); // NOI18N
        o.setName("o"); // NOI18N
        o.setPreferredSize(new java.awt.Dimension(39, 23));
        o.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                oActionPerformed(evt);
            }
        });
        o.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                oKeyPressed(evt);
            }
        });

        r.setText(resourceMap.getString("r.text")); // NOI18N
        r.setName("r"); // NOI18N
        r.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rActionPerformed(evt);
            }
        });
        r.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                rKeyPressed(evt);
            }
        });

        y.setText(resourceMap.getString("y.text")); // NOI18N
        y.setName("y"); // NOI18N
        y.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                yActionPerformed(evt);
            }
        });
        y.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                yKeyPressed(evt);
            }
        });

        q.setText(resourceMap.getString("q.text")); // NOI18N
        q.setName("q"); // NOI18N
        q.setPreferredSize(new java.awt.Dimension(39, 23));
        q.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                qActionPerformed(evt);
            }
        });
        q.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                qKeyPressed(evt);
            }
        });

        num6.setText(resourceMap.getString("num6.text")); // NOI18N
        num6.setName("num6"); // NOI18N
        num6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                num6ActionPerformed(evt);
            }
        });
        num6.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                num6KeyPressed(evt);
            }
        });

        num5.setText(resourceMap.getString("num5.text")); // NOI18N
        num5.setName("num5"); // NOI18N
        num5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                num5ActionPerformed(evt);
            }
        });
        num5.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                num5KeyPressed(evt);
            }
        });

        num4.setText(resourceMap.getString("num4.text")); // NOI18N
        num4.setName("num4"); // NOI18N
        num4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                num4ActionPerformed(evt);
            }
        });
        num4.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                num4KeyPressed(evt);
            }
        });

        num3.setText(resourceMap.getString("num3.text")); // NOI18N
        num3.setName("num3"); // NOI18N
        num3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                num3ActionPerformed(evt);
            }
        });
        num3.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                num3KeyPressed(evt);
            }
        });

        num2.setText(resourceMap.getString("num2.text")); // NOI18N
        num2.setName("num2"); // NOI18N
        num2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                num2ActionPerformed(evt);
            }
        });
        num2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                num2KeyPressed(evt);
            }
        });

        num1.setText(resourceMap.getString("num1.text")); // NOI18N
        num1.setName("num1"); // NOI18N
        num1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                num1ActionPerformed(evt);
            }
        });
        num1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                num1KeyPressed(evt);
            }
        });

        f.setText(resourceMap.getString("f.text")); // NOI18N
        f.setName("f"); // NOI18N
        f.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fActionPerformed(evt);
            }
        });
        f.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                fKeyPressed(evt);
            }
        });

        g.setText(resourceMap.getString("g.text")); // NOI18N
        g.setName("g"); // NOI18N
        g.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                gActionPerformed(evt);
            }
        });
        g.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                gKeyPressed(evt);
            }
        });

        n.setText(resourceMap.getString("n.text")); // NOI18N
        n.setName("n"); // NOI18N
        n.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nActionPerformed(evt);
            }
        });
        n.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                nKeyPressed(evt);
            }
        });

        m.setText(resourceMap.getString("m.text")); // NOI18N
        m.setName("m"); // NOI18N
        m.setPreferredSize(new java.awt.Dimension(39, 23));
        m.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mActionPerformed(evt);
            }
        });
        m.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                mKeyPressed(evt);
            }
        });

        j.setText(resourceMap.getString("j.text")); // NOI18N
        j.setName("j"); // NOI18N
        j.setPreferredSize(new java.awt.Dimension(39, 23));
        j.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jActionPerformed(evt);
            }
        });
        j.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jKeyPressed(evt);
            }
        });

        k.setText(resourceMap.getString("k.text")); // NOI18N
        k.setName("k"); // NOI18N
        k.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                kActionPerformed(evt);
            }
        });
        k.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                kKeyPressed(evt);
            }
        });

        h.setText(resourceMap.getString("h.text")); // NOI18N
        h.setName("h"); // NOI18N
        h.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hActionPerformed(evt);
            }
        });
        h.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                hKeyPressed(evt);
            }
        });

        i.setText(resourceMap.getString("i.text")); // NOI18N
        i.setName("i"); // NOI18N
        i.setPreferredSize(new java.awt.Dimension(39, 23));
        i.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                iActionPerformed(evt);
            }
        });
        i.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                iKeyPressed(evt);
            }
        });

        num8.setText(resourceMap.getString("num8.text")); // NOI18N
        num8.setName("num8"); // NOI18N
        num8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                num8ActionPerformed(evt);
            }
        });
        num8.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                num8KeyPressed(evt);
            }
        });

        num9.setText(resourceMap.getString("num9.text")); // NOI18N
        num9.setName("num9"); // NOI18N
        num9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                num9ActionPerformed(evt);
            }
        });
        num9.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                num9KeyPressed(evt);
            }
        });

        l.setText(resourceMap.getString("l.text")); // NOI18N
        l.setName("l"); // NOI18N
        l.setPreferredSize(new java.awt.Dimension(39, 23));
        l.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lActionPerformed(evt);
            }
        });
        l.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                lKeyPressed(evt);
            }
        });

        num0.setText(resourceMap.getString("num0.text")); // NOI18N
        num0.setName("num0"); // NOI18N
        num0.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                num0ActionPerformed(evt);
            }
        });
        num0.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                num0KeyPressed(evt);
            }
        });

        p.setText(resourceMap.getString("p.text")); // NOI18N
        p.setName("p"); // NOI18N
        p.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pActionPerformed(evt);
            }
        });
        p.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                pKeyPressed(evt);
            }
        });

        num7.setText(resourceMap.getString("num7.text")); // NOI18N
        num7.setName("num7"); // NOI18N
        num7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                num7ActionPerformed(evt);
            }
        });
        num7.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                num7KeyPressed(evt);
            }
        });

        c.setText(resourceMap.getString("c.text")); // NOI18N
        c.setName("c"); // NOI18N
        c.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cActionPerformed(evt);
            }
        });
        c.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                cKeyPressed(evt);
            }
        });

        v.setText(resourceMap.getString("v.text")); // NOI18N
        v.setName("v"); // NOI18N
        v.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vActionPerformed(evt);
            }
        });
        v.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                vKeyPressed(evt);
            }
        });

        d.setText(resourceMap.getString("d.text")); // NOI18N
        d.setName("d"); // NOI18N
        d.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dActionPerformed(evt);
            }
        });
        d.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                dKeyPressed(evt);
            }
        });

        e.setText(resourceMap.getString("e.text")); // NOI18N
        e.setName("e"); // NOI18N
        e.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                eActionPerformed(evt);
            }
        });
        e.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                eKeyPressed(evt);
            }
        });

        w.setText(resourceMap.getString("w.text")); // NOI18N
        w.setName("w"); // NOI18N
        w.setPreferredSize(new java.awt.Dimension(39, 23));
        w.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                wActionPerformed(evt);
            }
        });
        w.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                wKeyPressed(evt);
            }
        });

        t.setText(resourceMap.getString("t.text")); // NOI18N
        t.setName("t"); // NOI18N
        t.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tActionPerformed(evt);
            }
        });
        t.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tKeyPressed(evt);
            }
        });

        z.setText(resourceMap.getString("z.text")); // NOI18N
        z.setName("z"); // NOI18N
        z.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                zActionPerformed(evt);
            }
        });
        z.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                zKeyPressed(evt);
            }
        });

        u.setText(resourceMap.getString("u.text")); // NOI18N
        u.setName("u"); // NOI18N
        u.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                uActionPerformed(evt);
            }
        });
        u.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                uKeyPressed(evt);
            }
        });

        btnBarra.setText(resourceMap.getString("btnBarra.text")); // NOI18N
        btnBarra.setEnabled(false);
        btnBarra.setName("btnBarra"); // NOI18N
        btnBarra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBarraActionPerformed(evt);
            }
        });
        btnBarra.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                btnBarraKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(num1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(num2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(num3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(num4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(num5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(num6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(num7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(num8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(num9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(num0))
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
                                .addGap(21, 21, 21)
                                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(mainPanelLayout.createSequentialGroup()
                                        .addGap(111, 111, 111)
                                        .addComponent(btnAceptar, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(mainPanelLayout.createSequentialGroup()
                                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
                                                .addGap(31, 31, 31)
                                                .addComponent(z)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(x)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(c)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(v)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(b, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(n)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(m, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
                                                .addComponent(a, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(s)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(d)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(f)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(g)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(h)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(j, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(k)))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(l, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
                                .addComponent(q, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(2, 2, 2)
                                .addComponent(w, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(e)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(r)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(t)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(y)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(u)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(i, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(o, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(p))))
                    .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
                            .addComponent(parIzq, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btnAste, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(parDer, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btnBarra)
                            .addGap(8, 8, 8)
                            .addComponent(btnMas, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(btnBorrarTodo, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(14, Short.MAX_VALUE))
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(parIzq)
                    .addComponent(btnBorrarTodo)
                    .addComponent(btnAste)
                    .addComponent(parDer)
                    .addComponent(btnBarra)
                    .addComponent(btnMas))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(num1)
                    .addComponent(num2)
                    .addComponent(num3)
                    .addComponent(num4)
                    .addComponent(num5)
                    .addComponent(num6)
                    .addComponent(num7)
                    .addComponent(num8)
                    .addComponent(num9)
                    .addComponent(num0))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(q, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(w, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(e)
                    .addComponent(r)
                    .addComponent(t)
                    .addComponent(y)
                    .addComponent(u)
                    .addComponent(i, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(o, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(p))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(a)
                    .addComponent(s)
                    .addComponent(f)
                    .addComponent(g)
                    .addComponent(h)
                    .addComponent(j, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(k)
                    .addComponent(l, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(d))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(z)
                    .addComponent(x)
                    .addComponent(c)
                    .addComponent(v)
                    .addComponent(b)
                    .addComponent(n)
                    .addComponent(m, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnAceptar)
                .addContainerGap(15, Short.MAX_VALUE))
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(practica1.Practica1App.class).getContext().getActionMap(Practica1View.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 481, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 311, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(3, 3, 3))
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents

private void parIzqActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_parIzqActionPerformed
    expresion.setText(expresion.getText()+ "(");
    parIzq.setEnabled(true);
    parDer.setEnabled(false);
    a.setEnabled(true);
    b.setEnabled(true);
    btnMas.setEnabled(false);
    btnAste.setEnabled(false);
    btnBarra.setEnabled(false);
    numParentesis++;
    btnAceptar.setEnabled(false);
   
}//GEN-LAST:event_parIzqActionPerformed

private void aActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aActionPerformed
    expresion.setText(expresion.getText()+ "A");
    funcionTecla();
    
}//GEN-LAST:event_aActionPerformed
private void funcionTecla(){
    parIzq.setEnabled(true);
    btnBarra.setEnabled(true);
    btnMas.setEnabled(true);
    btnAste.setEnabled(true);
    if(numParentesis!=0)parDer.setEnabled(true);
    else parDer.setEnabled(false);
    if(numParentesis==0)btnAceptar.setEnabled(true);
    else btnAceptar.setEnabled(false);
}


private void btnMasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMasActionPerformed
    expresion.setText(expresion.getText()+ "+");
    btnMas.setEnabled(false);
    parIzq.setEnabled(true);
    a.setEnabled(true);
    b.setEnabled(true);
    btnAste.setEnabled(false);
    btnBarra.setEnabled(false);
    if(numParentesis!=0)parDer.setEnabled(true);
    else parDer.setEnabled(false);
    if(numParentesis==0)btnAceptar.setEnabled(true);
    else btnAceptar.setEnabled(false);
    
}//GEN-LAST:event_btnMasActionPerformed

private void btnAsteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAsteActionPerformed
   expresion.setText(expresion.getText()+ "*");
    btnAste.setEnabled(false);
    parIzq.setEnabled(true);
    a.setEnabled(true);
    b.setEnabled(true);
    btnMas.setEnabled(false);
    if(numParentesis!=0)parDer.setEnabled(true);
    else parDer.setEnabled(false);
    if(numParentesis==0)btnAceptar.setEnabled(true);
    else btnAceptar.setEnabled(false);
}//GEN-LAST:event_btnAsteActionPerformed

private void bActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bActionPerformed
    expresion.setText(expresion.getText()+ "B");
    funcionTecla();
}//GEN-LAST:event_bActionPerformed

private void parDerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_parDerActionPerformed
   expresion.setText(expresion.getText()+ ")");
    numParentesis--;
    parIzq.setEnabled(true);
    a.setEnabled(true);
    b.setEnabled(true);
    btnBarra.setEnabled(true);
    btnMas.setEnabled(true);
    btnAste.setEnabled(true);
    if(numParentesis==0)parDer.setEnabled(false);
    else parDer.setEnabled(true);
    if(numParentesis==0)btnAceptar.setEnabled(true);
    else btnAceptar.setEnabled(false);
}//GEN-LAST:event_parDerActionPerformed

private void btnBorrarTodoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBorrarTodoActionPerformed
    numParentesis=0;
    a.setEnabled(true);
    b.setEnabled(true);
    parIzq.setEnabled(true);
    parDer.setEnabled(false);
    btnBarra.setEnabled(false);
    btnMas.setEnabled(false);
    btnAste.setEnabled(false);
    btnAceptar.setEnabled(false);
    expresion.setText("");
}//GEN-LAST:event_btnBorrarTodoActionPerformed


private void mainPanelKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_mainPanelKeyPressed
    teclado(evt);
}//GEN-LAST:event_mainPanelKeyPressed

private void parIzqKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_parIzqKeyPressed
    teclado(evt);
}//GEN-LAST:event_parIzqKeyPressed

private void sActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sActionPerformed
    expresion.setText(expresion.getText()+ "S");
    funcionTecla();
}//GEN-LAST:event_sActionPerformed

private void dActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dActionPerformed
   expresion.setText(expresion.getText()+ "D");
   funcionTecla();
}//GEN-LAST:event_dActionPerformed

private void fActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fActionPerformed
    expresion.setText(expresion.getText()+ "F");
    funcionTecla();
}//GEN-LAST:event_fActionPerformed

private void gActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gActionPerformed
    expresion.setText(expresion.getText()+ "G");
    funcionTecla();
}//GEN-LAST:event_gActionPerformed

private void hActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hActionPerformed
    expresion.setText(expresion.getText()+ "H");
    funcionTecla();
}//GEN-LAST:event_hActionPerformed

private void jActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jActionPerformed
     expresion.setText(expresion.getText()+ "J");
     funcionTecla();
}//GEN-LAST:event_jActionPerformed

private void kActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kActionPerformed
    expresion.setText(expresion.getText()+ "K");
    funcionTecla();
}//GEN-LAST:event_kActionPerformed

private void lActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lActionPerformed
    expresion.setText(expresion.getText()+ "L");
    funcionTecla();
}//GEN-LAST:event_lActionPerformed

private void zActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zActionPerformed
   expresion.setText(expresion.getText()+ "Z");
   funcionTecla();
}//GEN-LAST:event_zActionPerformed

private void xActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_xActionPerformed
    expresion.setText(expresion.getText()+ "X");
    funcionTecla();
}//GEN-LAST:event_xActionPerformed

private void cActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cActionPerformed
    expresion.setText(expresion.getText()+ "C");
    funcionTecla();
}//GEN-LAST:event_cActionPerformed

private void vActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vActionPerformed
    expresion.setText(expresion.getText()+ "V");
    funcionTecla();
}//GEN-LAST:event_vActionPerformed

private void nActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nActionPerformed
    expresion.setText(expresion.getText()+ "N");
    funcionTecla();
}//GEN-LAST:event_nActionPerformed

private void mActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mActionPerformed
    expresion.setText(expresion.getText()+ "M");
    funcionTecla();
}//GEN-LAST:event_mActionPerformed

private void qActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_qActionPerformed
    expresion.setText(expresion.getText()+ "Q");
    funcionTecla();
}//GEN-LAST:event_qActionPerformed

private void wActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_wActionPerformed
    expresion.setText(expresion.getText()+ "W");
    funcionTecla();
}//GEN-LAST:event_wActionPerformed

private void eActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eActionPerformed
    expresion.setText(expresion.getText()+ "E");
    funcionTecla();
}//GEN-LAST:event_eActionPerformed

private void rActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rActionPerformed
    expresion.setText(expresion.getText()+ "R");
    funcionTecla();
}//GEN-LAST:event_rActionPerformed

private void tActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tActionPerformed
    expresion.setText(expresion.getText()+ "T");
    funcionTecla();
}//GEN-LAST:event_tActionPerformed

private void yActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_yActionPerformed
    expresion.setText(expresion.getText()+ "Y");
    funcionTecla();
}//GEN-LAST:event_yActionPerformed

private void uActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_uActionPerformed
    expresion.setText(expresion.getText()+ "U");
    funcionTecla();
}//GEN-LAST:event_uActionPerformed

private void iActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_iActionPerformed
    expresion.setText(expresion.getText()+ "I");
    funcionTecla();
}//GEN-LAST:event_iActionPerformed

private void oActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_oActionPerformed
    expresion.setText(expresion.getText()+ "O");
    funcionTecla();
}//GEN-LAST:event_oActionPerformed

private void pActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pActionPerformed
    expresion.setText(expresion.getText()+ "P");
    funcionTecla();
}//GEN-LAST:event_pActionPerformed

private void num1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_num1ActionPerformed
      expresion.setText(expresion.getText()+ "1");
      funcionTecla();
}//GEN-LAST:event_num1ActionPerformed

private void num2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_num2ActionPerformed
    expresion.setText(expresion.getText()+ "2");
    funcionTecla();
}//GEN-LAST:event_num2ActionPerformed

private void num3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_num3ActionPerformed
    expresion.setText(expresion.getText()+ "3");
    funcionTecla();
}//GEN-LAST:event_num3ActionPerformed

private void num4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_num4ActionPerformed
   expresion.setText(expresion.getText()+ "4");
   funcionTecla();
}//GEN-LAST:event_num4ActionPerformed

private void num5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_num5ActionPerformed
    expresion.setText(expresion.getText()+ "5");
    funcionTecla();
}//GEN-LAST:event_num5ActionPerformed

private void num6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_num6ActionPerformed
    expresion.setText(expresion.getText()+ "6");
    funcionTecla();
}//GEN-LAST:event_num6ActionPerformed

private void num7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_num7ActionPerformed
    expresion.setText(expresion.getText()+ "7");
    funcionTecla();
}//GEN-LAST:event_num7ActionPerformed

private void num8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_num8ActionPerformed
    expresion.setText(expresion.getText()+ "8");
    funcionTecla();
}//GEN-LAST:event_num8ActionPerformed

private void num9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_num9ActionPerformed
    expresion.setText(expresion.getText()+ "9");
    funcionTecla();
}//GEN-LAST:event_num9ActionPerformed

private void num0ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_num0ActionPerformed
   expresion.setText(expresion.getText()+ "0");
   funcionTecla();
}//GEN-LAST:event_num0ActionPerformed

private void btnBarraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBarraActionPerformed
   expresion.setText(expresion.getText()+ "|");
   parIzq.setEnabled(true);
   a.setEnabled(true);
   b.setEnabled(true);
   btnAste.setEnabled(false);
   btnBarra.setEnabled(false);
   btnMas.setEnabled(false);
   parDer.setEnabled(false);
   btnAceptar.setEnabled(false);
}//GEN-LAST:event_btnBarraActionPerformed

private void btnAsteKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_btnAsteKeyPressed
    teclado(evt);
}//GEN-LAST:event_btnAsteKeyPressed

private void parDerKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_parDerKeyPressed
    teclado(evt);
}//GEN-LAST:event_parDerKeyPressed

private void btnBarraKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_btnBarraKeyPressed
    teclado(evt);
}//GEN-LAST:event_btnBarraKeyPressed

private void btnMasKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_btnMasKeyPressed
    teclado(evt);
}//GEN-LAST:event_btnMasKeyPressed

private void btnBorrarTodoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_btnBorrarTodoKeyPressed
	teclado(evt);
}//GEN-LAST:event_btnBorrarTodoKeyPressed

private void expresionKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_expresionKeyPressed
    // TODO add your handling code here:
    teclado(evt);
}//GEN-LAST:event_expresionKeyPressed

private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed
    Thompson tompson=new Thompson(expresion.getText());
    btnBorrarTodoActionPerformed(evt);

}//GEN-LAST:event_btnAceptarActionPerformed

private void dKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dKeyPressed
    teclado(evt);
}//GEN-LAST:event_dKeyPressed

private void zKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_zKeyPressed
     teclado(evt);
}//GEN-LAST:event_zKeyPressed

private void num1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_num1KeyPressed
     teclado(evt);

}//GEN-LAST:event_num1KeyPressed

private void num2KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_num2KeyPressed
    teclado(evt);
}//GEN-LAST:event_num2KeyPressed

private void num3KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_num3KeyPressed
    teclado(evt);
}//GEN-LAST:event_num3KeyPressed

private void num4KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_num4KeyPressed
    teclado(evt);
}//GEN-LAST:event_num4KeyPressed

private void num5KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_num5KeyPressed
    teclado(evt);
}//GEN-LAST:event_num5KeyPressed

private void num6KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_num6KeyPressed
    // TODO add your handling code here:
}//GEN-LAST:event_num6KeyPressed

private void num7KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_num7KeyPressed
   teclado(evt);
}//GEN-LAST:event_num7KeyPressed

private void num8KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_num8KeyPressed
    teclado(evt);
}//GEN-LAST:event_num8KeyPressed

private void num9KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_num9KeyPressed
    teclado(evt);
}//GEN-LAST:event_num9KeyPressed

private void num0KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_num0KeyPressed
   teclado(evt);
}//GEN-LAST:event_num0KeyPressed

private void qKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_qKeyPressed
   teclado(evt);
}//GEN-LAST:event_qKeyPressed

private void wKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_wKeyPressed
    teclado(evt);
}//GEN-LAST:event_wKeyPressed

private void eKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_eKeyPressed
   teclado(evt);
}//GEN-LAST:event_eKeyPressed

private void rKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_rKeyPressed
    teclado(evt);
}//GEN-LAST:event_rKeyPressed

private void tKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tKeyPressed
     teclado(evt);
}//GEN-LAST:event_tKeyPressed

private void yKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_yKeyPressed
     teclado(evt);
}//GEN-LAST:event_yKeyPressed

private void uKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_uKeyPressed
     teclado(evt);
}//GEN-LAST:event_uKeyPressed

private void iKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_iKeyPressed
     teclado(evt);
}//GEN-LAST:event_iKeyPressed

private void oKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_oKeyPressed
     teclado(evt);
}//GEN-LAST:event_oKeyPressed

private void pKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_pKeyPressed
     teclado(evt);
}//GEN-LAST:event_pKeyPressed

private void aKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_aKeyPressed
     teclado(evt);
}//GEN-LAST:event_aKeyPressed

private void sKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_sKeyPressed
     teclado(evt);
}//GEN-LAST:event_sKeyPressed

private void fKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_fKeyPressed
     teclado(evt);
}//GEN-LAST:event_fKeyPressed

private void gKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_gKeyPressed
     teclado(evt);
}//GEN-LAST:event_gKeyPressed

private void hKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_hKeyPressed
     teclado(evt);
}//GEN-LAST:event_hKeyPressed

private void jKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jKeyPressed
     teclado(evt);
}//GEN-LAST:event_jKeyPressed

private void kKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_kKeyPressed
     teclado(evt);
}//GEN-LAST:event_kKeyPressed

private void lKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lKeyPressed
     teclado(evt);
}//GEN-LAST:event_lKeyPressed

private void xKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_xKeyPressed
    teclado(evt);
}//GEN-LAST:event_xKeyPressed

private void cKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cKeyPressed
     teclado(evt);
}//GEN-LAST:event_cKeyPressed

private void vKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_vKeyPressed
    teclado(evt);
}//GEN-LAST:event_vKeyPressed

private void bKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_bKeyPressed
     teclado(evt);
}//GEN-LAST:event_bKeyPressed

private void nKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nKeyPressed
     teclado(evt);
}//GEN-LAST:event_nKeyPressed

private void mKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_mKeyPressed
     teclado(evt);
}//GEN-LAST:event_mKeyPressed

private void btnAceptarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_btnAceptarKeyPressed
     teclado(evt);
}//GEN-LAST:event_btnAceptarKeyPressed


public void teclado(java.awt.event.KeyEvent tecla){

  if((tecla.getKeyCode()>=65 && tecla.getKeyCode()<=105)){
            expresion.setText(expresion.getText()+tecla.getKeyChar());
            expresion.setText(expresion.getText().toUpperCase());
            funcionTecla();
   }
    
    switch (tecla.getKeyCode()){
        case 56:
            if(shift==true && parIzq.isEnabled())parIzq.doClick();
            shift=false;           
            break;
        case 107:
            if(btnMas.isEnabled()) btnMas.doClick();
            shift=false;
            break;
        case 106:
            if(btnAste.isEnabled())btnAste.doClick();
            shift=false;
            break;
        case 57:
            if(shift==true && parDer.isEnabled())parDer.doClick();
            shift=false;
            break;
        case 16:
            shift=true;
            break;
        case 0:
            if(btnBarra.isEnabled())btnBarra.doClick();
            shift=false;
            break;
        case 8:
            btnBorrarTodo.doClick();
            shift=false;
            break;
        
    }
}

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton a;
    private javax.swing.JButton b;
    private javax.swing.JButton btnAceptar;
    private javax.swing.JButton btnAste;
    private javax.swing.JButton btnBarra;
    private javax.swing.JButton btnBorrarTodo;
    private javax.swing.JButton btnMas;
    private javax.swing.JButton c;
    private javax.swing.JButton d;
    private javax.swing.JButton e;
    private javax.swing.JTextArea expresion;
    private javax.swing.JButton f;
    private javax.swing.JButton g;
    private javax.swing.JButton h;
    private javax.swing.JButton i;
    private javax.swing.JButton j;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton k;
    private javax.swing.JButton l;
    private javax.swing.JButton m;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JButton n;
    private javax.swing.JButton num0;
    private javax.swing.JButton num1;
    private javax.swing.JButton num2;
    private javax.swing.JButton num3;
    private javax.swing.JButton num4;
    private javax.swing.JButton num5;
    private javax.swing.JButton num6;
    private javax.swing.JButton num7;
    private javax.swing.JButton num8;
    private javax.swing.JButton num9;
    private javax.swing.JButton o;
    private javax.swing.JButton p;
    private javax.swing.JButton parDer;
    private javax.swing.JButton parIzq;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JButton q;
    private javax.swing.JButton r;
    private javax.swing.JButton s;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JButton t;
    private javax.swing.JButton u;
    private javax.swing.JButton v;
    private javax.swing.JButton w;
    private javax.swing.JButton x;
    private javax.swing.JButton y;
    private javax.swing.JButton z;
    // End of variables declaration//GEN-END:variables

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private int opcion;
    private boolean shift;
    private JDialog aboutBox;
}
